package com.cndw.kungfu.model;

import java.io.Serializable;

import com.cndw.kungfu.core.CacheDataBase;
import com.cndw.kungfu.core.CacheDataKey;
import com.cndw.kungfu.model.pvp.war.WarWorldData;

/**
 * 华山论剑,天下第一数据保存
 * @author fantadust [9677889@qq.com]
 * @date 2012-8-8 下午4:32:52
 */
public class WarWorldSerialize extends CacheDataBase implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7024956230993646298L;

	private static WarWorldSerialize instance = null;
	
	private WarWorldData warWorldData;

	private WarWorldSerialize() {
	}

	@Override
	public String getKey() {
		return CacheDataKey.keyWarWorldSerialize;
	}

	public static WarWorldSerialize getInstance() {
		if (instance == null) {
			synchronized (WarWorldSerialize.class) {
				if (instance == null) {
					CacheDataBase cacheData = Context.getSysServer().initCacheData(CacheDataKey.keyWarWorldSerialize);
					if (cacheData != null && cacheData instanceof WarWorldSerialize) {
						instance = (WarWorldSerialize) cacheData;
					}
					if (instance == null) {
						instance = new WarWorldSerialize();
					}
					if (instance.getSyncDBTime() == 0) {
						instance.commitSync();
					}
				}
			}

		}
		return instance;

	}

	public WarWorldData getWarWorldData() {
		if (warWorldData == null) {
			synchronized (WarWorldSerialize.class) {
				if (warWorldData == null ) {
					warWorldData = new WarWorldData();
				}
			}
			
		}
		return warWorldData;
	}
	
	

}
